import request from '@/api/axios'
import {AxiosPromise} from 'axios'
import {DataRecordList, DataRes} from '@/api/config'
import {RowOperbuttons} from '@/components/dTable/dTable'

export interface DiagnosticTableParams {
  page?: number
  limit?: number
  idNo?: string // 身份证号
  phyDate?: Array<string> //体检日期
  startDate?: string //体检开始日期
  endDate?: string // 体检结束日期
  minAge?: string // 最小年龄
  maxAge?: string // 最大年龄
  registerStatus?: number // 体检状态
  notTestCategoryIdsArr?: Array<string> // 未检大类ids数组
  notTestCategories?: string // 未检大类名称，英文逗号分隔
}

export interface DiagnosticTableList {
  id: number //id
  checkupNo: string //体检号
  registerStatus: number //体检状态
  personName: string //姓名
  gender: string //性别
  age: string //年龄
  address: string //居住地址
  pastHistory: string //既往史
}
// 体检医生列表
export interface DoctorList {
  id: string
  userName: string
}

/**
 * @description: 获取医生诊台分页
 * @return {*}
 */
export const getDiagnosticTable = (params: DiagnosticTableParams): AxiosPromise<DataRecordList<DiagnosticTableList & RowOperbuttons>> => {
  return request({
    url: '/api/checkupRegister/diagnosticTable/page',
    method: 'get',
    params
  })
}

/**
 * @description: 获取体检医生列表
 * @return {*}
 */
export const getDoctorList = (): AxiosPromise<DataRes<Array<DoctorList>>> => {
  return request({
    url: '/api/user/doctor/list',
    method: 'get'
  })
}

/**
 * @description: 拒检
 * @param {string} id 体检登记表id
 * @return {*}
 */
export const rejectCheckupRegister = (id: string): AxiosPromise<DataRes<null>> => {
  return request({
    url: `/api/checkupRegister/reject/${id}`,
    method: 'post'
  })
}


/**
 * @description: 获取必填项校验字段
 * @param {*} AxiosPromise
 * @return {*}
 */
export const getFieldRequired = (): AxiosPromise<DataRes<Array<string>>> => {
  return request({
    url: '/api/itemField/getCheckField',
    method: 'get'
  })
}